#include <iostream>
#include <fstream>
#include <ctime>
#include <vector>

using namespace std;

vector <int> fail (vector <int> arr){
  for (int i = 0; i < arr.size(); i++){
    int k = 0;
    for (int j = 0; j < arr.size(); j++){
      if (arr[j] > arr[j+1]){
        int t = arr[j];
        arr[j] = arr[j + 1];
        arr[j + 1] = t;
        k++;
      }
    }
    if (k == 0){
      break;
    }
  }
  return arr;
}

int main() {
  ifstream f1;
  f1.open("m1_sorted.txt");
  vector <int> arr;
  int x;
  while (f1 >> x){
    arr.push_back(x);
  }
  vector <int> fail(vector <int> arr);
  double start = clock();
  arr = fail(arr);
  double end = clock();
  cout << "m1_sorted.txt " << (end - start) / 1000 << " millisecond" << endl;
  ifstream f2;
  f2.open("m1_sorted.txt");
  vector <int> arr1;
  int s1;
  while(f2 >> s1){
    arr1.push_back(s1);
  }
  vector <int> fail(vector <int> a1);
  double start1 = clock();
  arr1 = fail(arr1);
  double end1 = clock();
  cout << "m2_reverse.txt " << (end1 - start1) / 1000 << " millisecond" << endl;
  ifstream s2;
  s2.open("m3_shuffle.txt");
  vector <int> arr2;
  int c2;
  while(s2 >> c2){
    arr2.push_back(c2);
  }
  vector <int> fail(vector <int> arr2);
  double start2 = clock();
  arr2 = fail(arr2);
  double end2 = clock();
  cout << "m3_shuffle.txt " << (end2 - start2) / 1000 << " millisecond" << endl;
}